package com.spring.partypark.web.controller;



import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.mangofactory.swagger.annotations.ApiIgnore;
import com.spring.partypark.web.service.PartyParkService;
import com.spring.security.core.util.ApplicationUtils;
@Controller
@RequestMapping(value = "/partyPark")
@ApiIgnore
public class PartyParkController {
	
	@Resource
	private PartyParkService partyParkService;
	


	//获取主题
	@RequestMapping(value = "/getThemeList")
	@ResponseBody
    public Object getThemeList(String name,String callback) {
   
        Map<String, Object> m = new HashMap<String, Object>();
		try {

			m  = partyParkService.getThemeList(name);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

    	
    	if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }
        
    }
	
	
	//预约
	@RequestMapping(value = "/appoint")
	@ResponseBody
    public Object appoint(String token, String party_themeID, String serviceTargetID, String serviceTargetName,String peopleNumber, String executeTime, String kids_parkID,String callback) {
   
        Map<String, Object> m = new HashMap<String, Object>();
		try {

			m  = partyParkService.appoint(token, party_themeID, serviceTargetID, serviceTargetName,peopleNumber,executeTime,kids_parkID);
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

    	
    	if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }
        
    }
		
		//获取预约列表
		@RequestMapping(value = "/getAppointmentList")
		@ResponseBody
	    public Object getAppointmentList(String token,String party_appointmentID, String page_size, String page_index, String skip, String rows,
	    	String callback) {
	   
	        Map<String, Object> m = new HashMap<String, Object>();
			try {

				m  = partyParkService.getAppointmentList(token,party_appointmentID, page_size, page_index, skip, rows);
						
			} catch (Exception e) {
				m.put(ApplicationUtils.STATUS, "0");
				m.put(ApplicationUtils.MSG, "系统异常");
				e.printStackTrace();

			}

	    	
	    	if(ApplicationUtils.isNotNull(callback)){
	        	return new JSONPObject(callback, m);
	        }else{
	        	return m;
	        }
	        
	    }

		 //取消预约
		@RequestMapping(value = "/cancelAppointment")
		@ResponseBody
	    public Object cancelAppointment(String token, String party_appointmentID,String callback) {
	   
	        Map<String, Object> m = new HashMap<String, Object>();
			try {

				m  = partyParkService.cancelAppointment(token, party_appointmentID);
						
			} catch (Exception e) {
				m.put(ApplicationUtils.STATUS, "0");
				m.put(ApplicationUtils.MSG, "系统异常");
				e.printStackTrace();

			}

	    	
	    	if(ApplicationUtils.isNotNull(callback)){
	        	return new JSONPObject(callback, m);
	        }else{
	        	return m;
	        }
	        
	    }
		

		
		 //反馈
		@RequestMapping(value = "/feedback")
		@ResponseBody
	    public Object feedback(String token, String party_appointmentID, String feedback,String callback) {
	   
	        Map<String, Object> m = new HashMap<String, Object>();
			try {

				m  = partyParkService.feedback(token, party_appointmentID, feedback);
						
			} catch (Exception e) {
				m.put(ApplicationUtils.STATUS, "0");
				m.put(ApplicationUtils.MSG, "系统异常");
				e.printStackTrace();

			}

	    	
	    	if(ApplicationUtils.isNotNull(callback)){
	        	return new JSONPObject(callback, m);
	        }else{
	        	return m;
	        }
	        
	    }
}

